<html>
<head>
<!-- Copyright (c) GoAhead Software Inc., 1995-2010. All Rights Reserved. -->
<title>brealloc -- basic</title>
<link rel="stylesheet" href="../../../style/doc.css" type="text/css">
</head>

<body>
 <table class=apitable> <tr><td>
<table border=0 width=100% cellspacing=0 cellpadding=0 CLASS="apiTitle">
<tr>
	<td class="titleLeft" align=left width="33%"><b> brealloc</b></td><td class="titleCenter" align=center width="33%"><b> basic</b></td><td class="titleRight" align=right width="33%"><B> EMF</B></td></tr>
</table><hr>
<h2>Synopsis</h2><p>Reallocate a block of memory.</p><h2>Prototype</h2><pre>
 #include &quot;uemf.h&quot;

 void *<b>brealloc</b>(B_ARGS_DEC, void* mp, int newsize);
</pre><h2>Parameters</h2><table width=100% BORDER="0" CELLPADDING="0" CELLSPACING="0">
    
    <tr>
        
    <td width="11%">B_ARGS_DEC</td><td width="89%">Caller's source file name and line number. Really two arguments.</td></tr>
    <tr>
        
    <td width="11%">mp</td><td width="89%">Pointer to a previously allocated memory block using balloc.</td></tr>
    <tr>
        
    <td width="11%">newsize</td><td width="89%">New size, in bytes.</td></tr>
</table><h2>Description</h2><p> 
The GoAhead equivalent of realloc.
</p><p><B>Note:</B> Allows NULL pointers. Will just do a balloc on the size if 
  that is the case.</p><h2>Return Value</h2><p> 
Return pointer to newly allocated block.  If the realloc fails, NULL is returned,
and the previous buffer is preserved.
</p><h2>Example</h2><pre>
/***********************************************************************/
/*
 *    Add a character to a string buffer
 */

static void put_char(strbuf_t *buf, char_t c)
{
    if (buf->count >= buf->size) {
        if (! (buf->flags & STR_REALLOC)) {
            return;
        }
        buf->size += STR_INC;
        if (buf->size > buf->max && buf->size > STR_INC) {
            a_assert(buf->size <= buf->max);
            buf->size -= STR_INC;
            return;
        }
        if (buf->s == NULL) {
            buf->s = balloc(B_L, buf->size * sizeof(char_t));
        } else {
            buf->s = brealloc(B_L, buf->s, buf->size * sizeof(char_t));
        }
    }
    buf->s[buf->count] = c;
    ++buf->count;
}
</pre><h2>Stability Classification</h2><p>Stable.</p><h2></h2><h2></h2><h2>See Also</h2><p>
<a href="balloc.htm">balloc</a>,
<a href="bfree.htm">bfree</a></p></td></tr></table>
</body>
</html>
